programming4us
           
 
 
Programming

jQuery 1.3 : Improving a basic form (part 1) - Progressively enhanced form styling

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/6/2010 9:14:06 AM
As we apply jQuery to websites, we must always ask ourselves how pages will look and function when JavaScript is unavailable to our visitors (unless, of course, we know exactly who every visitor will be and how their browsers will be configured). This is not to say, however, that we can't create a more beautiful or feature-full site for visitors with JavaScript turned on. The principle of progressive enhancement is popular among JavaScript developers because it respects the needs of all users while providing something extra to most of them. To demonstrate progressive enhancement with respect to forms, we'll create a contact form that we can improve in both appearance and behavior using jQuery.

Progressively enhanced form styling

First, let's make some aesthetic tweaks to our form. Without JavaScript enabled, the form's first fieldset is rendered like this:

While it certainly appears functional, and contains plenty of information to guide the user through each field, it could definitely stand some improvement. We'll progressively enhance this group in three ways:

  1. 1. Modify the DOM to allow for flexible styling of the<legend>.

  2. 2. Change the required field message (required) to an asterisk (*) and the special field message (required only when the corresponding checkbox is checked) to a double asterisk (**). Bold the label for each required field and place a key at the top of the form explaining what the asterisk and double asterisk mean.

  3. 3. Hide each checkbox's corresponding text input on page load, and then toggle them, visible and hidden, when the user checks and unchecks the boxes.

We start with the<fieldset>'s HTML:


<fieldset>
<legend>Personal Info</legend>
<ol>
<li>
<label for="first-name">First Name</label>
<input class="required" type="text" name="first-name"
id="first-name" />
<span>(required)</span>
</li>
<li>
<label for="last-name">Last Name</label>
<input class="required" type="text" name="last-name"
id="last-name" />
<span>(required)</span>
</li>
<li>How would you like to be contacted?
(choose at least one method)
<ul>
<li>
<label for="by-email">
<input type="checkbox" name="by-contact-type"
value="E-mail" id="by-email" />
by E-Mail
</label>
<input class="conditional" type="text" name="email"
id="email" />
<span>(required when corresponding checkbox
checked)</span>
</li>
<li>
<label for="by-phone">
<input type="checkbox" name="by-contact-type"
value="Phone" id="by-phone" />
by Phone
</label>
<input class="conditional" type="text" name="phone"
id="phone" />
<span>(required when corresponding checkbox
checked)</span>
</li>
<li>
<label for="by-fax">
<input type="checkbox" name="by-contact-type"
value="Fax" id="by-fax" />
by Fax
</label>
<input class="conditional" type="text" name="fax"
id="fax" />
<span>(required when corresponding checkbox
checked)</span>
</li>
</ul>
</li>
</ol>
</fieldset>



One thing to note here is that each element or pair of elements is considered a list item (<li>). All elements are placed within an ordered list (<ol>), and the checkboxes (along with their text fields) are placed within a nested unordered list (<ul>). Furthermore, we use the<label> element to indicate the name of each field. For text fields, the<label> precedes the<input>; for checkboxes, it encloses the<input>. While there is no "standard" element structure for elements within a fieldset, the ordered list seems to come as close as anything to representing the semantic meaning of the items in a contact form.

With our HTML in place, we're now ready to use jQuery for the progressive enhancement.
Other -----------------
- Changes to Privacy Risk Management and Compliance in Relation to Cloud Computing
- Cloud Security and Privacy : What Are the Key Privacy Concerns in the Cloud?
- Cloud Security and Privacy : What Is the Data Life Cycle?
- Making Your Site Accessible to Search Engines
- Security Management in the Cloud - Security Vulnerability, Patch, and Configuration Management (part 2)
- Security Management in the Cloud - Security Vulnerability, Patch, and Configuration Management (part 1)
- Security Management in the Cloud - Access Control
- Security Management in the Cloud - IaaS Availability Management
- Security Management in the Cloud - PaaS Availability Management
- Security Management in the Cloud - SaaS Availability Management
- Security Management in the Cloud - Availability Management
- Security Management in the Cloud
- The Art of SEO : Trending, Seasonality, and Seasonal Fluctuations in Keyword Demand
- The Art of SEO : Leveraging the Long Tail of Keyword Demand
- The Art of SEO : Determining Keyword Value/Potential ROI
- Identity and Access Management : Cloud Service Provider IAM Practice
- Identity and Access Management : Cloud Authorization Management
- Identity and Access Management : IAM Practices in the Cloud (part 2) - Federated Identity
- Identity and Access Management : IAM Practices in the Cloud (part 1) - Cloud Identity Administration
- iPad SDK : Keyboard Extensions and Replacements (part 4) - Creating the Calculator
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us